package day04

import org.apache.spark.streaming.dstream.ReceiverInputDStream
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.apache.spark.{SparkConf, SparkContext}

/**
  * 接收scoket数据流进行单词统计
  * local[N] N>1 大于1是因为一个线程需要运行当前main方法中的程序，还有线程需要接收其他数据
  * streaming 处理有时间的概念
  */
object AcceptScoketData {
  def main(args: Array[String]): Unit = {
    val sparkConf: SparkConf = new SparkConf().setAppName("AcceptScoketData").setMaster("local[2]")
    val sc: SparkContext = new SparkContext(sparkConf)
    val ssc: StreamingContext = new StreamingContext(sc,Seconds(5))
    //接收scoket数据
    val stream: ReceiverInputDStream[String] = ssc.socketTextStream("node01",9999)
    println(stream)
  }
}
